package com.sharecode.stock.strategy;

import com.sharecode.stock.init.StockInit;
import com.sharecode.stock.strategy.norm.boll.BOLLNorm;
import com.sharecode.stock.strategy.norm.kdj.KdjNorm;
import com.sharecode.stock.strategy.norm.macd.MacdNorm;
import com.sharecode.stock.strategy.process.macd.MacdProcess;
import com.sharecode.stock.strategy.vo.StrategyVo;
import com.sharecode.stock.vo.stock.StockHistory;

import lombok.extern.slf4j.Slf4j;

@Slf4j
public class CalculateHandle {
	public static boolean init_all = false;

	public static void handle(StockHistory stockHistory) {
		try {
			StrategyVo vo = StockInit.STRATEGY_VO_MAP.get(stockHistory.getCode()+"-"+stockHistory.getCycle());
			vo.getStockHistories().add(stockHistory);
			if (vo.getStockHistories().size() < 30) {
				return;
			}
			// macd指标
			MacdNorm.getInstance().handle(vo);
			// kdj指标
			KdjNorm.getInstance().handle(vo);
			// boll指标
			BOLLNorm.getInstance().handle(vo);

			// macd预处理
			MacdProcess.getInstance().process(vo);
			if (!vo.isInit()) {
				return;
			}
			if (!init_all) {
				return;
			}
//			// **********************策略*******************
//			MacdDeviateStrategy.strategy(vo);// macd背离
			MacdAndKdjStrategy.strategy(vo);// 组合策略
		} catch (Exception e) {
			log.info("异常:", e);
		}
	}
}
